package com.mallcloud.mall.mall.api.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.mallcloud.mall.common.core.constant.enums.mall.OrderEnum;
import com.mallcloud.mall.common.core.util.ValidGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

@ApiModel(value = "MallOrderModel", description = "mall订单")
@Data
@TableName("SYS_ORDER")
public class MallOrderModel implements Serializable {
	private static final long serialVersionUID = 1L;

	@JsonSerialize(using = ToStringSerializer.class)
	@NotNull(message = "id为空", groups = {ValidGroup.Update.class})
	@TableId(value = "ID", type = IdType.ASSIGN_ID)
	@ApiModelProperty("编号")
	private Long id;

	@ApiModelProperty("订单号")
	@TableField("ORDER_NO")
	private String orderNo;

	/**
	 * {@link OrderEnum.StatusEnum}
	 */
	@ApiModelProperty("订单状态")
	@TableField("STATUS")
	private Integer status;

	/**
	 * {@link OrderEnum.PayedEnum}
	 */
	@ApiModelProperty("是否已支付")
	@TableField("PAYED")
	private Boolean hasPayed;

	@ApiModelProperty("交易金额")
	@TableField("MONEY")
	private BigDecimal money;

	@ApiModelProperty("优惠金额")
	@TableField("DISCOUNT_AMOUT")
	private BigDecimal discountAmount;

	@ApiModelProperty("最终金额")
	@TableField("FINAL_MONEY")
	private BigDecimal finalMoney;

	/**
	 * {@link OrderEnum.DiscountTypeEnum}
	 */
	@ApiModelProperty("优惠类型")
	@TableField("DISCOUNT_TYPE")
	private Integer discountType;

	@ApiModelProperty("优惠券号")
	@TableField("COUPON_NO")
	private String couponNo;

	@ApiModelProperty("优惠券抵扣金额")
	@TableField("COUPON_MONEY")
	private BigDecimal couponMoney;

	@ApiModelProperty("顾客手机号")
	@TableField("PHONE")
	private String phone;

	@ApiModelProperty("顾客卡号")
	@TableField("CARD_NO")
	private String cardNo;

	@ApiModelProperty("商户号")
	@TableField("MCH_ID")
	private String mchId;

	@ApiModelProperty("门店号")
	@TableField("MKT")
	private String storeNo;

	@ApiModelProperty("pos终端号")
	@TableField("POSKEY")
	private String posKey;

	@ApiModelProperty("支付时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@TableField("PAY_TIME")
	private Date payTime;

	@ApiModelProperty("创建时间")
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@TableField(value = "create_Time", fill = FieldFill.INSERT)
	private Date createTime;

	@ApiModelProperty("订单版本号，每处理一次订单，版本号+1")
	@TableField("VERSION")
	private Integer version;

	@ApiModelProperty("备注")
	@TableField("REMARK")
	private String remark;

	@ApiModelProperty("失败原因")
	@TableField("EXCEPTIONS")
	private String exceptions;

	@ApiModelProperty("业务类型")
	@TableField("ORDER_TYPE")
	private String orderType;

	@ApiModelProperty("业务数据")
	@TableField("ATTACH")
	private String attach;

}
